跳到主要内容

1 首页接口开发

1.1 需求分析

  • 需求说明:

在前台系统首页展示商品一级分类数据以及畅销商品列表数据,如下所示:

image-20230703225931377

  • 需求分析:

1、商品一级分类:查询category表,获取parent_id="0"的数据列表

2、畅销商品列表:查询product_sku表,根据sale_num字段排序,取前20条数据列表

  • 整体的访问流程,如下所示:

image-20230707081332596

1.2 接口开发

对比着接口文档进行相关接口的开发。

  • 查看接口文档:

首页接口地址及示例数据

get  /api/product/index
返回结果:
{
"code": 200,
"message": "成功",
"data": {
"productSkuList": [
{
"id": 1,
"createTime": "2023-05-25 22:21:07",
"skuCode": "1_0",
"skuName": "小米 红米Note10 5G手机 颜色:白色 内存:8G",
"productId": 1,
"thumbImg": "http://139.198.127.41:9000/spzx/20230525/665832167-5_u_1 (1).jpg",
"salePrice": 1999.00,
"marketPrice": 2019.00,
"costPrice": 1599.00,
"stockNum": 99,
"saleNum": 1,
"skuSpec": "颜色:白色,内存:8G",
"weight": "1.00",
"volume": "1.00",
"status": null,
"skuSpecList": null
},
...
],
"categoryList": [
{
"id": 1,
"createTime": "2023-05-22 23:30:28",
"name": "数码办公",
"imageUrl": "https://lilishop-oss.oss-cn-beijing.aliyuncs.com/230f48f024a343c6be9be72597c2dcd0.png",
"parentId": 0,
"status": 1,
"orderNum": 1,
"hasChildren": null,
"children": null
},
...
]
}
}